package com.learn.config;

import com.learn.bean.A;
import com.learn.bean.B;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/03/12
 * @description 测试条件注解
 */
@ConditionalOnClass(name = "org.springframework.web.servlet.DispatcherServlet")
@Configuration
public class BeanConfig {
    // 未指定id时，方法名就是默认的beanid
    @Bean
    public A objectA() {
        return new A();
    }
    @Bean
    @ConditionalOnBean(A.class)
    public B objectB() {
        return new B();
    }
}
